﻿using Microsoft.Win32;
using SimpleMvvmDemoByMyself.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimpleMvvmDemoByMyself.ViewModels
{
    public class MainWindowViewModel : NotificationObjects
    {
        private double num1;

        public double Num1
        {
            get { return num1; }
            set
            {
                num1 = value;
                this.RaisePropertyChanged("Num1");
            }
        }

        private double num2;

        public double Num2
        {
            get { return num2; }
            set
            {
                num2 = value;
                this.RaisePropertyChanged("Num2");
            }
        }

        private double result;

        public double Result
        {
            get { return result; }
            set
            {
                result = value;
                this.RaisePropertyChanged("Result");
            }
        }

        public void Add(object parameter)
        {
            this.Result = this.Num1 + this.Num2;
        }

        public void Save(object p)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.ShowDialog();
        }

        public DelegateCommand AddCommand { get; set; }
        public DelegateCommand SaveCommand { get; set; }

        public MainWindowViewModel()
        {
            this.AddCommand = new DelegateCommand();
            this.SaveCommand = new DelegateCommand();

            this.AddCommand.ExecuteAction = new Action<object>(this.Add);
            this.SaveCommand.ExecuteAction = new Action<object>(this.Save);
        }


    }
}
